#include <iostream>
#include <cstdio>
using namespace std;

int main(){
	int y,m,days=0;
	cin>>y>>m;
	switch(m){
		case 4:case 6:case 9:case 11: days=30;break;
		case 2:days=28+((y%4==0&&y%100!=0)||(y%400==0));break;
		default: days=31;
	} 
	cout<<days;
	return 0;
}
